<template>
  <div :class="flags?'shuiguo':'shuiguos'">
    <div class="shang">
      <span class="iconfont icon-fanhui" @click="fanhui()"></span>
      <p>生鲜水果</p>
      <div class="tou">
        <span class="iconfont icon-dian"></span>
        <div class="zhongjian"></div>
        <span class="iconfont icon-shuangyuanquan"></span>
      </div>
    </div>
    <div class="zhong">
      <div class="huayuan">
        <span class="iconfont icon-ziyuan"></span>
        <p>嘉宾花园店</p>
        <span class="iconfont icon-qianjin"></span>
      </div>
      <div class="sousuos">
        <span class="iconfont icon-sousuo"></span>
      </div>
    </div>
    <div class="xia">
      <ul class="xiashang">
        <li v-for="(item,index) in data" :key="index" @click="liang(index)">
          <p :class="active===index?'liang':''">{{item.name}}</p>
        </li>
      </ul>
      <ul class="xiazhong">
        <li
          v-for="(item,index) in list" :key="index" @click="liangs(index)" :class="tive===index?'liangs':''">{{item.name}}</li>
      </ul>
      <div class="lunbo">
        <Lunbo />
      </div>
      <ul :class="flag?'xiaxia':'xiaxias'">
        <li v-for="(item,index) in this.$store.state.shuiguoxiang" :key="index">
          <div class="xialeft">
            <img :src="item.src" />
          </div>
          <div class="xiaright">
            <h1>{{item.name}}</h1>
            <div class="xiarightzhong">
              <div class="xiarightleft">
                <p class="hong">{{item.price}}</p>
                <p>{{item.dizhi}}</p>
              </div>
              <div class="xiarightright">
                <p class="lan">{{item.juli}}</p>
                <span>+</span>
              </div>
            </div>
            <p class="shou">已售{{item.shouchu}}</p>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import Lunbo from "./lunbo.vue";

export default {
  name: "",
  components: {
    Lunbo
  },
  data() {
    return {
      data: [
        {
          name: "推荐"
        },
        {
          name: "辛集餐饮"
        },
        {
          name: "色酷啦"
        },
        {
          name: "小鸟伏特加"
        },
        {
          name: "中泰厨师"
        }
      ],
      list: [
        {
          name: "综合排序"
        },
        {
          name: "距离"
        },
        {
          name: "销量"
        }
      ],
      active: 0,
      tive: 0,
      flag: false,
      flags: true
    };
  },
  methods: {
    liang(index) {
      this.active = index;
      console.log(index)
      this.$store.commit("shuiguoxiang", index);
    },
    liangs(index) {
      this.tive = index;
    },
    fanhui() {
      this.flags = false;
      setTimeout(() => {
        history.back()
      }, 300);
    }
  },
  mounted() {
    setTimeout(() => {
      this.flag = true;
    }, 20);
  },
  created() {
    this.$store.commit("shuiguo", 1);
  },
};
</script>

<style scoped>
@import url("../../../../../assets/fonts2/iconfont.css");
.shuiguo {
  width: 100vw;
  height: 100vh;
  background: #fff;
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(0, 0);
  transition: all 300ms;
  z-index: 3;
}
.shuiguos {
  width: 100%;
  height: 100%;
  background: #fff;
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(100vw, 0);
  transition: all 300ms;
}
.shang {
  width: 100%;
  height: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.shang > span {
  margin-left: 10px;
}
.ding {
  width: 100%;
  height: 30px;
}
.ding img {
  width: 100%;
  height: 30px;
}
.tou {
  width: 100px;
  height: 30px;
  background: rgba(145, 145, 145);
  border-top-right-radius: 15px;
  border-bottom-right-radius: 15px;
  border-top-left-radius: 15px;
  border-bottom-left-radius: 15px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-right: 10px;
}
.zhongjian {
  width: 1px;
  height: 60%;
  background: #fff;
}
.zhong {
  width: 100%;
  height: 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.huayuan {
  width: 150px;
  height: 40px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.sousuos {
  width: 50px;
  height: 40px;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.xia {
  width: 96%;
  margin: 0 auto;
}
.xiashang {
  width: 500px;
  height: 40px;
}
.xiashang li {
  padding: 0 20px 0 0;
  float: left;
  line-height: 40px;
}
.xiashang li .liang {
  line-height: 15px;
  display: inline-block;
  border-bottom: 5px solid yellow;
}
.xiazhong {
  width: 100%;
  height: 40px;
  display: flex;
}
.xiazhong li {
  padding: 0 20px 0 0;
  line-height: 40px;
}
.xiazhong .liangs {
  color: yellowgreen;
}
.lunbo {
  width: 100%;
  height: 100px;
}
.xiaxia {
  width: 100%;
  transform: translate(0, 0);
  transition: all 500ms;
}
.xiaxias {
  width: 100%;
  transform: translate(0, 20vh);
  transition: all 500ms;
}
.xiaxia li {
  width: 100%;
  height: 100px;
  display: flex;
  border-bottom: 1px solid #c1c1c1;
}
.xiaxia li .xialeft {
  width: 30%;
  height: 100%;
}
.xiaxia li .xiaright {
  width: 70%;
  height: 100%;
}
.xiaxia li .xialeft img {
  width: 95%;
  height: 94%;
  margin: 3% 0;
}
.xiaright h1 {
  font-size: 16px;
  line-height: 30px;
}
.xiaright .xiarightzhong {
  width: 100%;
  height: 40%;
  display: flex;
  justify-content: space-between;
}
.xiarightleft p {
  font-size: 15px;
}
.xiarightleft .hong {
  color: red;
}
.xiarightright .lan {
  color: blue;
  font-size: 15px;
}
.xiarightright span {
  display: inline-block;
  width: 30px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  background: yellow;
  border-radius: 50%;
}
.xiaright .shou {
  font-size: 15px;
  line-height: 25px;
}
</style>